package net.lab1024.sa.admin.module.business.erp.bas.controller;

import net.lab1024.sa.admin.module.business.erp.bas.domain.form.UnitAddForm;
import net.lab1024.sa.admin.module.business.erp.bas.domain.form.UnitQueryForm;
import net.lab1024.sa.admin.module.business.erp.bas.domain.form.UnitUpdateForm;
import net.lab1024.sa.admin.module.business.erp.bas.domain.vo.UnitVO;
import net.lab1024.sa.admin.module.business.erp.bas.service.UnitService;
import net.lab1024.sa.base.common.domain.ValidateList;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import net.lab1024.sa.base.common.domain.ResponseDTO;
import net.lab1024.sa.base.common.domain.PageResult;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;

import javax.annotation.Resource;
import javax.validation.Valid;

/**
 * 单位 Controller
 *
 * @Author AKITA
 * @Date 2025-07-23 17:13:13
 * @Copyright AKITA
 */

@RestController
@Tag(name = "单位")
public class UnitController {

    @Resource
    private UnitService unitService;

    @Operation(summary = "分页查询 @author AKITA")
    @PostMapping("/unit/queryPage")

    public ResponseDTO<PageResult<UnitVO>> queryPage(@RequestBody @Valid UnitQueryForm queryForm) {
        return ResponseDTO.ok(unitService.queryPage(queryForm));
    }

    @Operation(summary = "添加 @author AKITA")
    @PostMapping("/unit/add")

    public ResponseDTO<String> add(@RequestBody @Valid UnitAddForm addForm) {
        return unitService.add(addForm);
    }

    @Operation(summary = "更新 @author AKITA")
    @PostMapping("/unit/update")

    public ResponseDTO<String> update(@RequestBody @Valid UnitUpdateForm updateForm) {
        return unitService.update(updateForm);
    }

    @Operation(summary = "批量删除 @author AKITA")
    @PostMapping("/unit/batchDelete")

    public ResponseDTO<String> batchDelete(@RequestBody ValidateList<String> idList) {
        return unitService.batchDelete(idList);
    }

    @Operation(summary = "单个删除 @author AKITA")
    @GetMapping("/unit/delete/{id}")

    public ResponseDTO<String> batchDelete(@PathVariable String id) {
        return unitService.delete(id);
    }
}
